/**   
 * @Title: NewMyInfoAct.java 
 * @Package: com.esun.rabbit2.viewer.mainact.mylotteryact.myinfo 
 * @Description: 个人信息查看修改activity
 * @Author: Billy qigs@500wan.com   
 * @Date: 2011-8-5 下午05:30:31  
 * Copyright (C) 2011 Shenzhen E-sun Sky Net Technology Co.,ltd.
 */
package com.esun.rabbit2.viewer.mainact.mylotteryact.myinfo;

import android.app.Activity;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.text.method.PasswordTransformationMethod;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnFocusChangeListener;
import android.view.View.OnTouchListener;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RadioButton;
import android.widget.ScrollView;
import android.widget.TextView;
import android.widget.Toast;

import com.esun.config.Config;
import com.esun.config.Language;
import com.esun.model.UserInfo;
import com.esun.model.UserInfoDetailInfo;
import com.esun.network.ConnectionChangeReceiver;
import com.esun.rabbit2.communicaters.myinfo.ModifyUserInfoCommunicater;
import com.esun.rabbit2.communicaters.myinfo.MyInfoCommunicater;
import com.esun.ui.R;
import com.esun.util.ViewerUtil;
import com.esun.util.img.ImageUtils;
import com.esun.util.img.db.ImageDB;
import com.esun.util.log.EDebug;
import com.esun.util.md5.MD5;

/**
 * @ClassName: NewMyInfoAct
 * @Description: 个人信息查看修改activity
 * @Author: Billy qigs@500wan.com
 * @Date: 2011-8-5 下午05:30:31
 */
public class NewMyInfoAct extends Activity implements OnClickListener, OnFocusChangeListener, OnCheckedChangeListener, OnTouchListener {

	private ImageButton btnBack;
	private ImageButton btnRefresh;
	private Button btnSubmit;
	private Button btnYes;
	private Handler handler;
	private ProgressDialog progress;
	private MyInfoCommunicater communicater = new MyInfoCommunicater();
	private ModifyUserInfoCommunicater modifyCommunicater = new ModifyUserInfoCommunicater();
	private ImageView imgAvatar;
	private InputMethodManager imm;
	private ScrollView scrollView;

	private LinearLayout linearMain;
	private LinearLayout linearInfo;
	private LinearLayout linearBaseInfo;
	private LinearLayout linearSafeInfo;
	private LinearLayout linearMobileText;
	private FrameLayout frameMobileEdit;
	private LinearLayout linearEmail;
	private FrameLayout frameEmail;
	private LinearLayout linearPostCode;
	private FrameLayout framePostCode;
	private LinearLayout linearAddress;
	private FrameLayout frameAddress;

	private LinearLayout btnBaseInfo;
	private LinearLayout btnSecretInfo;
	private ImageView imgBaseInfo;
	private ImageView imgSecretInfo;

	private TextView tvUserName;
	private TextView tvBalance;
	private TextView tvRealUserName;
	private TextView tvIDNum;
	private TextView tvBankNum;
	private TextView tvEMail;
	private TextView tvAddress;
	private TextView tvPostCode;
	private TextView tvMobile;
	private EditText etEMail;
	private EditText etAddress;
	private EditText etPostCode;
	private EditText etMobile;
	private Button btnCleanMobile;
	private Button btnCleanEmail;
	private Button btnCleanPostCode;
	private Button btnCleanAddress;

	private RadioButton rbMale;
	private RadioButton rbFemale;
	private RadioButton rbSerect;

	private String strUserName;
	private String strAddress;
	private String strPostCode;
	private String strSex;
	private String strMobile;
	private String strEmail;
	private String strIDNum;
	private String strRealName;
	private String strBankNum;
	private String strPassword;
	private String strBalance;
	private String strUserIConName;

	/** 当前页面标识 0-基础信息 1-安全信息 */
	private int pageFlag = 0;

	private static final int GET_USERINFO_SUCCESS = 1001;
	private static final int GET_USERINFO_FAILED = 1002;
	private static final int REPLACE_IMAGE = 1003;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.myinfo_act_third);

		init();
		initHandler();
		startGetInfo();
	}

	private void init() {

		progress = ViewerUtil.showProgressDialog(this, "请稍后...");
		progress.show();

		imgAvatar = (ImageView) findViewById(R.id.myinfo_act_third_iv_userIcon);

		btnBack = (ImageButton) findViewById(R.id.myinfo_act_third_btn_goBack);
		btnBack.setOnClickListener(this);
		btnRefresh = (ImageButton) findViewById(R.id.myinfo_act_third_btn_refresh);
		btnRefresh.setOnClickListener(this);
		btnSubmit = (Button) findViewById(R.id.myinfo_act_third_btn_submit);
		btnSubmit.setOnClickListener(this);

		tvUserName = (TextView) findViewById(R.id.myinfo_act_third_tv_userName);
		tvBalance = (TextView) findViewById(R.id.myinfo_act_third_tv_userBalance);
		tvRealUserName = (TextView) findViewById(R.id.myinfo_act_third_tv_userRealName);
		tvIDNum = (TextView) findViewById(R.id.myinfo_act_third_tv_userIDNum);
		tvBankNum = (TextView) findViewById(R.id.myinfo_act_third_tv_userBankNum);
		tvMobile = (TextView) findViewById(R.id.myinfo_act_third_tv_userMobile);
		tvMobile.setOnClickListener(this);
		tvEMail = (TextView) findViewById(R.id.myinfo_act_third_tv_userEmail);
		tvEMail.setOnClickListener(this);
		tvAddress = (TextView) findViewById(R.id.myinfo_act_third_tv_userAddress);
		tvAddress.setOnClickListener(this);
		tvPostCode = (TextView) findViewById(R.id.myinfo_act_third_tv_userPostCode);
		tvPostCode.setOnClickListener(this);
		etMobile = (EditText) findViewById(R.id.myinfo_act_third_et_userMobile);
		etMobile.setOnFocusChangeListener(this);
		etEMail = (EditText) findViewById(R.id.myinfo_act_third_et_userEmail);
		etEMail.setOnFocusChangeListener(this);
		etAddress = (EditText) findViewById(R.id.myinfo_act_third_et_userAddress);
		etAddress.setOnFocusChangeListener(this);
		etPostCode = (EditText) findViewById(R.id.myinfo_act_third_et_userPostCode);
		etPostCode.setOnFocusChangeListener(this);

		linearMobileText = (LinearLayout) findViewById(R.id.myinfo_act_third_linear_mobileText);
		frameMobileEdit = (FrameLayout) findViewById(R.id.myinfo_act_third_frame_mobileEdit);
		btnCleanMobile = (Button) findViewById(R.id.myinfo_act_third_btn_claenUserMobile);
		btnCleanMobile.setOnClickListener(this);

		linearEmail = (LinearLayout) findViewById(R.id.myinfo_act_third_linear_emailText);
		frameEmail = (FrameLayout) findViewById(R.id.myinfo_act_third_frame_emailEdit);
		btnCleanEmail = (Button) findViewById(R.id.myinfo_act_third_btn_claenUserEmail);
		btnCleanEmail.setOnClickListener(this);

		linearPostCode = (LinearLayout) findViewById(R.id.myinfo_act_third_linear_postCodeText);
		framePostCode = (FrameLayout) findViewById(R.id.myinfo_act_third_frame_postCodeEdit);
		btnCleanPostCode = (Button) findViewById(R.id.myinfo_act_third_btn_claenUserPostCode);
		btnCleanPostCode.setOnClickListener(this);

		linearAddress = (LinearLayout) findViewById(R.id.myinfo_act_third_linear_addressText);
		frameAddress = (FrameLayout) findViewById(R.id.myinfo_act_third_frame_addressEdit);
		btnCleanAddress = (Button) findViewById(R.id.myinfo_act_third_btn_claenUserAddress);
		btnCleanAddress.setOnClickListener(this);

		btnBaseInfo = (LinearLayout) findViewById(R.id.myinfo_act_third_linear_baseinfo);
		btnBaseInfo.setOnTouchListener(this);
		btnSecretInfo = (LinearLayout) findViewById(R.id.myinfo_act_third_linear_secretinfo);
		btnSecretInfo.setOnTouchListener(this);
		imgBaseInfo = (ImageView) findViewById(R.id.myinfo_act_third_img_baseinfo);
		imgSecretInfo = (ImageView) findViewById(R.id.myinfo_act_third_img_secretinfo);

		rbFemale = (RadioButton) findViewById(R.id.myinfo_act_third_rb_female);
		rbFemale.setOnCheckedChangeListener(this);
		rbMale = (RadioButton) findViewById(R.id.myinfo_act_third_rb_male);
		rbMale.setOnCheckedChangeListener(this);
		rbSerect = (RadioButton) findViewById(R.id.myinfo_act_third_rb_secret);
		rbSerect.setOnCheckedChangeListener(this);

		linearMain = (LinearLayout) findViewById(R.id.myinfo_act_third_linear_main);
		linearMain.setOnClickListener(this);
		linearInfo = (LinearLayout) findViewById(R.id.myinfo_act_third_linear_info);
		linearInfo.setOnClickListener(this);
		linearBaseInfo = (LinearLayout) findViewById(R.id.myinfo_act_third_linear_baseInfo);
		linearSafeInfo = (LinearLayout) findViewById(R.id.myinfo_act_third_linear_safeInfo);

		imm = (InputMethodManager) this.getSystemService(INPUT_METHOD_SERVICE);
		scrollView = (ScrollView) findViewById(R.id.myinfo_act_third_scrollview);
		scrollView.setOnClickListener(this);

	}

	private void initHandler() {

		handler = new Handler() {

			@Override
			public void handleMessage(Message msg) {
				super.handleMessage(msg);

				switch (msg.what) {
				case GET_USERINFO_SUCCESS:

					communicater.updateUserInfo();
					clearFocused();
					updateString();
					refreshUI();
					getAvatar();
					progressCancle();

					break;

				case GET_USERINFO_FAILED:

					ViewerUtil.showTipDialog(NewMyInfoAct.this, "获取用户信息失败！", false);
					progressCancle();

					break;

				case REPLACE_IMAGE:

					Bitmap bm = (Bitmap) msg.obj;
					imgAvatar.setImageBitmap(bm);

					break;

				case MODIFY_INFO_SUCCEED:

					Toast.makeText(NewMyInfoAct.this, "修改成功，刷新个人信息", Toast.LENGTH_SHORT).show();
					startGetInfo();

					break;

				case MODIFY_INFO_FAILED:

					ViewerUtil.showTipDialog(NewMyInfoAct.this, "个人信息修改失败:" + modifyCommunicater.getServerMsg(), false);
					EDebug.o(this, modifyCommunicater.getServerMsg());
					progressCancle();

					break;

				case Config.CONNECTION_FAIL:
					Toast.makeText(NewMyInfoAct.this, Language.STR_CONNECTIONFAIL, Toast.LENGTH_SHORT).show();
					// ViewerUtil.showTipDialog(NewMyInfoAct.this, Language.STR_CONNECTIONFAIL, false);
					progressCancle();

					break;

				default:
					break;
				}
			}
		};
	}

	private void progressCancle() {
		if (progress != null) {
			progress.cancel();
		}
	}

	private void updateString() {

		strUserName = UserInfoDetailInfo.getUserInfoDetailInfo().getUserName();
		strAddress = UserInfoDetailInfo.getUserInfoDetailInfo().getAddress();
		strBankNum = UserInfoDetailInfo.getUserInfoDetailInfo().getBankNum();
		strEmail = UserInfoDetailInfo.getUserInfoDetailInfo().getEmail();
		strIDNum = UserInfoDetailInfo.getUserInfoDetailInfo().getIDNum();
		strMobile = UserInfoDetailInfo.getUserInfoDetailInfo().getMobileNum();
		strPostCode = UserInfoDetailInfo.getUserInfoDetailInfo().getPostCode();
		strRealName = UserInfoDetailInfo.getUserInfoDetailInfo().getRealName();
		strSex = UserInfoDetailInfo.getUserInfoDetailInfo().getSex();
		strUserIConName = UserInfoDetailInfo.getUserInfoDetailInfo().getuserIconName();
		strBalance = UserInfoDetailInfo.getUserInfoDetailInfo().getBalance();

	}

	// 用户信息显示
	public void refreshUI() {

		tvBalance.setText(Language.POPLOTTERYTIP_RMB + strBalance);
		// 银行卡隐藏后六位
		tvBankNum.setText(showData(strBankNum, 0));
		// 身份证隐藏月份日期四位
		tvIDNum.setText(showData(strIDNum, 1));
		// 手机号隐藏第四位到第七位
		tvMobile.setText(showData(strMobile, 2));
		// 用户名只显示第一位
		tvRealUserName.setText(showData(strRealName, 3));
		// 不需要隐藏
		tvAddress.setText(showData(strAddress, 4));
		tvEMail.setText(showData(strEmail, 5));
		tvPostCode.setText(showData(strPostCode, 6));
		tvUserName.setText(showData(strUserName, 7));
		// 判断性别
		if (strSex.equals(Config.NUM0)) {
			// 保密
			rbSerect.setChecked(true);
		} else if (strSex.equals(Config.NUM1)) {
			// 男
			rbMale.setChecked(true);
		} else if (strSex.equals(Config.NUM2)) {
			// 女
			rbFemale.setChecked(true);
		}

	}

	// index 0-银行卡1-身份证2-手机号3-用户名4-地址5-邮箱6-邮政编码
	private String showData(String str, int index) {

		if (!isEmpty(str)) {
			switch (index) {
			case 0:
				return hideTransfer(str, strBankNum.length() - 5, strBankNum.length());

			case 1:
				return hideTransfer(str, strIDNum.length() - 7, strIDNum.length() - 4);

			case 2:
				return hideTransfer(str, 4, 7);

			case 3:
				return hideTransfer(str, 2, strRealName.length());

			default:
				return str;
			}
		} else {
			return Language.MSG_MYINFO_WEIBANGDING;
		}
	}

	// 判断是否为空
	private boolean isEmpty(String str) {
		if (str == null || str.length() <= 0) {
			return true;
		} else {
			return false;
		}
	}

	// 数据隐藏
	private String hideTransfer(String str, int start, int end) {
		// 判断end和start是否下标越界
		if (start < 0 || start > str.length() || end < 0 || end > str.length() || start > end) {
			return str;
		}
		// 重新组织数据，隐藏部分信息
		StringBuilder strShowNum = new StringBuilder();
		// 将字符串分隔成单个字符
		String[] strTmp = str.split("|");
		for (int i = 0; i < strTmp.length; i++) {
			if (i > start - 1 && i <= end) {
				strShowNum = strShowNum.append(Config.XINGHAO);
			} else {
				strShowNum = strShowNum.append(strTmp[i]);
			}
		}
		return strShowNum.toString();
	}

	@Override
	public void onClick(View v) {

		switch (v.getId()) {

		case R.id.myinfo_act_third_scrollview:

			clearFocused();

			break;

		case R.id.myinfo_act_third_linear_main:

			clearFocused();

			break;

		case R.id.myinfo_act_third_linear_info:

			clearFocused();

			break;

		case R.id.myinfo_act_third_btn_goBack:

			NewMyInfoAct.this.finish();

			break;

		case R.id.myinfo_act_third_btn_refresh:

			startGetInfo();

			break;

		case R.id.myinfo_act_third_btn_submit:

			showInputPasswordDialog(NewMyInfoAct.this);

			break;

		case R.id.myinfo_act_third_tv_userMobile:

			linearMobileText.setVisibility(View.GONE);
			frameMobileEdit.setVisibility(View.VISIBLE);
			etMobile.requestFocus();
			etMobile.setText(strMobile);

			break;

		case R.id.myinfo_act_third_tv_userAddress:

			linearAddress.setVisibility(View.GONE);
			frameAddress.setVisibility(View.VISIBLE);
			etAddress.requestFocus();
			etAddress.setText(strAddress);

			break;

		case R.id.myinfo_act_third_tv_userEmail:

			linearEmail.setVisibility(View.GONE);
			frameEmail.setVisibility(View.VISIBLE);
			etEMail.requestFocus();
			etEMail.setText(strEmail);

			break;

		case R.id.myinfo_act_third_tv_userPostCode:

			linearPostCode.setVisibility(View.GONE);
			framePostCode.setVisibility(View.VISIBLE);
			etPostCode.requestFocus();
			etPostCode.setText(strPostCode);

			break;

		case R.id.myinfo_act_third_btn_claenUserMobile:

			etMobile.setText(Config.NULLMARK);

			break;

		case R.id.myinfo_act_third_btn_claenUserPostCode:

			etPostCode.setText(Config.NULLMARK);

			break;

		case R.id.myinfo_act_third_btn_claenUserEmail:

			etEMail.setText(Config.NULLMARK);

			break;

		case R.id.myinfo_act_third_btn_claenUserAddress:

			etAddress.setText(Config.NULLMARK);

			break;

		default:
			break;
		}
	}

	// 获取用户信息线程
	private void startGetInfo() {

		progress.show();

		new Thread() {

			@Override
			public void run() {
				super.run();

				doGetInfo();

			}
		}.start();
	}

	// 获取用户信息
	private void doGetInfo() {

		try {
			if (communicater.getMyInfo()) {

				Message msg = handler.obtainMessage(GET_USERINFO_SUCCESS);
				handler.sendMessage(msg);

			} else {
				Message msg = handler.obtainMessage(GET_USERINFO_FAILED);
				handler.sendMessage(msg);
			}
		} catch (Exception e) {
			Message msg = handler.obtainMessage(Config.CONNECTION_FAIL);
			handler.sendMessage(msg);
		}

	}

	// 获取用户头像
	private void getAvatar() {
		new Thread() {

			@Override
			public void run() {
				super.run();

				Bitmap bm = null;
				ImageDB.getImageDB().open(NewMyInfoAct.this);

				bm = ImageUtils.getLocalImg(strUserIConName);

				if (bm == null) {
					bm = ImageUtils.downLoadImg(strUserIConName);
					if (bm != null) {
						Message msg = handler.obtainMessage(REPLACE_IMAGE, bm);
						handler.sendMessage(msg);
						ImageUtils.saveImg(strUserIConName, bm);
					}
				} else {
					Message msg = handler.obtainMessage(REPLACE_IMAGE, bm);
					handler.sendMessage(msg);
				}
				ImageDB.getImageDB().close();
			}
		}.start();
	}

	@Override
	protected void onPause() {
		super.onPause();
		this.unregisterReceiver(ConnectionChangeReceiver.getConnectionChangeReceiver());
	}

	@Override
	protected void onResume() {
		super.onResume();
		this.registerReceiver(ConnectionChangeReceiver.getConnectionChangeReceiver(), ConnectionChangeReceiver.getIntentFilter());
	}

	// 清除所有焦点
	private void clearFocused() {

		etAddress.clearFocus();
		etEMail.clearFocus();
		etMobile.clearFocus();
		etPostCode.clearFocus();

	}

	@Override
	public void onFocusChange(View v, boolean hasFocus) {
		EDebug.o(this, "on focuse change ");
		switch (v.getId()) {

		case R.id.myinfo_act_third_et_userAddress:

			if (hasFocus) {
				imm.showSoftInput(etAddress, 0);
			} else {
				imm.hideSoftInputFromWindow(etAddress.getWindowToken(), 0);
				strAddress = etAddress.getText().toString();
				frameAddress.setVisibility(View.GONE);
				linearAddress.setVisibility(View.VISIBLE);
				tvAddress.setText(showData(strAddress, 4));
			}

			break;

		case R.id.myinfo_act_third_et_userEmail:

			if (hasFocus) {
				imm.showSoftInput(etEMail, 0);
			} else {
				imm.hideSoftInputFromWindow(etEMail.getWindowToken(), 0);
				strEmail = etEMail.getText().toString();
				frameEmail.setVisibility(View.GONE);
				linearEmail.setVisibility(View.VISIBLE);
				tvEMail.setText(showData(strEmail, 5));
			}

			break;

		case R.id.myinfo_act_third_et_userPostCode:

			if (hasFocus) {
				imm.showSoftInput(etPostCode, 0);
			} else {
				imm.hideSoftInputFromWindow(etPostCode.getWindowToken(), 0);
				strPostCode = etPostCode.getText().toString();
				framePostCode.setVisibility(View.GONE);
				linearPostCode.setVisibility(View.VISIBLE);
				tvPostCode.setText(showData(strPostCode, 6));
			}

			break;

		case R.id.myinfo_act_third_et_userMobile:

			if (hasFocus) {
				imm.showSoftInput(etMobile, 0);
			} else {
				imm.hideSoftInputFromWindow(etMobile.getWindowToken(), 0);
				strMobile = etMobile.getText().toString();
				frameMobileEdit.setVisibility(View.GONE);
				linearMobileText.setVisibility(View.VISIBLE);
				tvMobile.setText(showData(strMobile, 2));
			}

			break;

		}
	}

	// 性别选择和资料选择
	@Override
	public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
		switch (buttonView.getId()) {

		case R.id.myinfo_act_third_rb_female:

			if (isChecked) {
				strSex = "2";// 女
			}

			break;

		case R.id.myinfo_act_third_rb_male:

			if (isChecked) {
				strSex = "1";// 男
			}

			break;

		case R.id.myinfo_act_third_rb_secret:

			if (isChecked) {
				strSex = "0";// 保密
			}
			break;

		default:
			break;
		}
	}

	// 修改用户信息
	private static final int MODIFY_INFO_SUCCEED = 1000008;
	private static final int MODIFY_INFO_FAILED = 1000009;

	private void ModifyUserInfoThread() {
		new Thread() {

			@Override
			public void run() {
				super.run();
				Message msg = new Message();
				try {
					boolean isSucceed = false;
					isSucceed = modifyCommunicater.modifyUserInfo(strPassword, strAddress, strMobile, strEmail, strPostCode, strSex);
					if (isSucceed) {
						msg = handler.obtainMessage(MODIFY_INFO_SUCCEED, null);
					} else {
						msg = handler.obtainMessage(MODIFY_INFO_FAILED, null);
					}
				} catch (Exception e) {
					msg = handler.obtainMessage(Config.CONNECTION_FAIL, null);
				}
				handler.sendMessage(msg);
			}
		}.start();
	}

	public void showInputPasswordDialog(final Context context) {
		final Dialog inputPwdDialog = new Dialog(context, R.style.dialog);
		inputPwdDialog.getWindow().setContentView(R.layout.dialog_edittext_continuebuyl);
		btnYes = (Button) inputPwdDialog.getWindow().findViewById(R.id.dialog_continue_btn_yes);
		((TextView) inputPwdDialog.getWindow().findViewById(R.id.dialog_edittext_tv_infoBefore)).setText("");
		((TextView) inputPwdDialog.getWindow().findViewById(R.id.dialog_edittext_tv_infoBehind)).setText("");
		((TextView) inputPwdDialog.getWindow().findViewById(R.id.dialog_deittext_tv_titleTop)).setText("请输入您的500WAN账户密码");
		((TextView) inputPwdDialog.getWindow().findViewById(R.id.dialog_deittext_tv_title)).setText("用户名：" + UserInfo.getUserInfo().getUserName());

		final EditText edtPwd = (EditText) inputPwdDialog.getWindow().findViewById(R.id.dialog_continuebuy_et_fenShu);
		edtPwd.setTransformationMethod(PasswordTransformationMethod.getInstance());
		imm.showSoftInput(edtPwd, 0);
		btnYes.setText("确定");
		btnYes.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				imm.hideSoftInputFromWindow(edtPwd.getWindowToken(), 0);
				if (edtPwd.getText() != null && edtPwd.getText().toString() != "") {
					String strPwd = edtPwd.getText().toString();
					strPassword = strPwd;
					if (strPwd.length() != 32) {
						strPwd = MD5.md5(strPwd);
					}
					if (strPwd.equals(UserInfo.getUserInfo().getUserPwd())) {
						UserInfo.getUserInfo().setInputPasswordTime();
						EDebug.o(this, "" + UserInfo.getUserInfo().getInputPasswordTime());
						inputPwdDialog.cancel();
						// Toast.makeText(context, "密码正确，修改用户信息", 500).show();
						progress.show();
						clearFocused();
						ModifyUserInfoThread();
					} else {
						Toast.makeText(context, "密码错误,请重新输入", Toast.LENGTH_SHORT).show();
						edtPwd.setText(null);
					}
				} else {
					Toast.makeText(context, "请输入密码", Toast.LENGTH_SHORT).show();
				}
			}
		});
		Button btnNo = (Button) inputPwdDialog.getWindow().findViewById(R.id.dialog_continue_btn_no);
		btnNo.setText("取消");
		btnNo.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				inputPwdDialog.cancel();
			}
		});
		inputPwdDialog.show();
	}

	@Override
	public boolean onTouch(View v, MotionEvent event) {

		switch (v.getId()) {

		case R.id.myinfo_act_third_linear_secretinfo:

			if (event.getAction() == MotionEvent.ACTION_DOWN) {

				btnSecretInfo.setBackgroundResource(R.drawable.tab_pressed_userinformation_tab_147x30);

			} else if (event.getAction() == MotionEvent.ACTION_UP) {

				pageFlag = 1;
				linearBaseInfo.setVisibility(View.GONE);
				linearSafeInfo.setVisibility(View.VISIBLE);
				btnBaseInfo.setBackgroundResource(R.drawable.tab_default_userinformation_tab_147x30);
				btnSecretInfo.setBackgroundResource(R.drawable.tab_pressed_userinformation_tab_149x31);
				imgBaseInfo.setImageResource(R.drawable.icon_default_id_00x00);
				imgSecretInfo.setImageResource(R.drawable.icon_pressed_lock_00x00);

			} else if (event.getAction() == MotionEvent.ACTION_CANCEL) {

				EDebug.o(this, "划出点击区域");
				if (pageFlag == 0) {
					btnSecretInfo.setBackgroundResource(R.drawable.tab_default_userinformation_tab_147x30);
				} else {
					btnSecretInfo.setBackgroundResource(R.drawable.tab_pressed_userinformation_tab_149x31);
				}

			}

			break;

		case R.id.myinfo_act_third_linear_baseinfo:

			if (event.getAction() == MotionEvent.ACTION_DOWN) {

				btnBaseInfo.setBackgroundResource(R.drawable.tab_pressed_userinformation_tab_147x30);

			} else if (event.getAction() == MotionEvent.ACTION_UP) {

				pageFlag = 0;
				linearBaseInfo.setVisibility(View.VISIBLE);
				linearSafeInfo.setVisibility(View.GONE);
				btnBaseInfo.setBackgroundResource(R.drawable.tab_pressed_userinformation_tab_149x31);
				btnSecretInfo.setBackgroundResource(R.drawable.tab_default_userinformation_tab_147x30);
				imgBaseInfo.setImageResource(R.drawable.icon_pressed_id_00x00);
				imgSecretInfo.setImageResource(R.drawable.icon_default_lock_00x00);

			} else if (event.getAction() == MotionEvent.ACTION_CANCEL) {

				EDebug.o(this, "划出点击区域");
				if (pageFlag == 0) {
					btnBaseInfo.setBackgroundResource(R.drawable.tab_pressed_userinformation_tab_149x31);
				} else {
					btnBaseInfo.setBackgroundResource(R.drawable.tab_default_userinformation_tab_147x30);
				}
			}

			break;

		default:

			break;
		}

		return true;
	}
}